import { NedbModel, NedbDao } from './NedbDao';
import Job from '../job/Job';
import JobStatus from '../job/JobStatus';

export class JobModel extends NedbModel {
  queueName: string
  url: string
  tryNum: number
  status: JobStatus
  jobSerialize: string

  constructor(job: Job) {
    super(job.getId())
    this.url = job.getUrl()
    this.queueName = job.queueName
    this.tryNum = job.tryNum
    this.status = job.status
    this.createTime = job.getCreateTime()
    this.updateTime = new Date().getTime()
    this.jobSerialize = JSON.stringify(job)
  }
}

export class JobDao extends NedbDao<JobModel> {

}